<template>
  <div>
    {{ count === 0 ? "获取验证码" : count + "s之后在获取" }}
    <button @click="start">开始定时器</button>
    <!-- <button @click="pause">暂停定时器</button>
    <button @click="resume">继续定时器</button> -->

    
  </div>
</template>

<script>
import { useIntervalFn } from "@vueuse/core";
import { useCountDown } from "@/compositions";
import { ref } from "vue";
export default {
  name: "playGround",
  setup() {
    /*
    pause===暂停
    resume==开启
    isActive===false：暂停，true:开启
    */

    // const { countTime, start, pause, resume } = useCountDown(5);
    // return { countTime, start };
    const count = ref(0);
    const userStart = (n) => {
      var timer = setInterval(() => {
        if (count.value <= 0) {
          clearInterval(timer);
          return;
        }
        count.value--;
      }, 1000);
    };
    const start = () => {
      count.value = 5;
      userStart();
    };
    return { start, count };
  },
};
</script>
